package com.xm.concurrent.base;

import javax.net.ssl.ManagerFactoryParameters;
import java.lang.management.ManagementFactory;
import java.lang.management.ThreadInfo;
import java.lang.management.ThreadMXBean;
import java.util.logging.Logger;

/**
 * 4.1 线程简介
 * @author xiaoming
 * @date 2021-05-18 22:48
 */
public class MultiThread {
    private static final Logger logger = Logger.getGlobal();

    public static void main(String[] args) {
        // 获取 Java线程管理器 MXBean
        ThreadMXBean threadMXBean = ManagementFactory.getThreadMXBean();
        // 获取线程堆栈信息
        ThreadInfo[] threadInfos = threadMXBean.dumpAllThreads(false, false);
        // 遍历线程信息
        for (ThreadInfo threadInfo : threadInfos) {
            logger.info(threadInfo.getThreadId() + " - " + threadInfo.getThreadName() );
        }
    }

}
